package day13;

import java.io.*;

public class BytelOdEMO {
    public static void main(String[] args) {
        copyFile("src/test/FileDem.java","src/test/FileDemaasd.java");
    }
    public  static  void copyFile(String src, String target){
        InputStream in=null;
        OutputStream out=null;
        try {
            in=new FileInputStream(src);
            out=new FileOutputStream(target);
            byte[]buf=new byte[3*1024];
            while (true){
                int len=in.read(buf);
                if (len == -1)
                    break;
                out.write(buf,0,len);
                System.out.println("文件拷贝");
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }  finally{
                if(null!=in){
                        try {
                            in.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
            }
                if (null!=out){

                    try {
                        out.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                }
        }
    }
}
